package org.wishwork.api.order.sent;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wishwork.api.Api;
import org.wishwork.context.Context;
import org.wishwork.helper.HttpHelper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @description: 订单发货
 * @author: WangYX
 * @create: 2022-04-13 13:38
 * @Version: 1.0.0
 **/

public class OrderSentApi extends Api<OrderSentResponse, List<OrderSentRequest>> {

    private static final Logger log = LoggerFactory.getLogger(OrderSentApi.class);

    private Context context;

    public OrderSentApi(Context context) {
        this.context = context;
    }

    @Override
    protected String query(List<OrderSentRequest> orderSentRequests) throws Exception {
        String url = "/open/ordersent/upload";
        List<Map<String, Object>> list = new ArrayList();
        for (OrderSentRequest orderSentRequest : orderSentRequests) {
            Map<String, Object> map = new HashMap<>();
            map.put("shop_id", orderSentRequest.getShopId());
            map.put("o_id", orderSentRequest.getOId());
            map.put("so_id", orderSentRequest.getSoId());
            map.put("lc_name", orderSentRequest.getLcName());
            map.put("l_id", orderSentRequest.getLId());
            map.put("lc_id", orderSentRequest.getLcId());
            list.add(map);
        }
        Map<String, Object> params = new HashMap<>();
        params.put("list", list);
        return HttpHelper.sendRequest(params, url);
    }

    @Override
    protected OrderSentResponse process(JSONObject data, List<OrderSentRequest> orderSentRequests) throws Exception {
        return null;
    }
}
